﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PhatPhucLoc.model;
using System.Data;
using PhatPhucLoc.util;
using System.Data.SqlClient;

namespace PhatPhucLoc.dao
{
    class ChiTietHoaDonDAO
    {
        public static DataTable GetAll()
        {
            return DataUtil.executeStore("sp_ChiTietHoaDon_GetAll", null);
        }

        public static Boolean Insert(ChiTietHoaDonModel _model)
        {
            SqlParameter[] param = new SqlParameter[4];
            int i = 0;
            param[i] = new SqlParameter("MaHoaDon", SqlDbType.NVarChar);
            param[i++].Value = _model.MaHoaDon;
            param[i] = new SqlParameter("MaSanPham", SqlDbType.NVarChar);
            param[i++].Value = _model.MaSanPham;
            param[i] = new SqlParameter("GiaTien", SqlDbType.NVarChar);
            param[i++].Value = _model.GiaTien;
            param[i] = new SqlParameter("SoLuong", SqlDbType.NVarChar);
            param[i++].Value = _model.SoLuong;
            return DataUtil.executeNonStore("sp_ChiTietHoaDon_Insert", param);
        }

        public static Boolean Update(KhoHangModel _model)
        {
            SqlParameter[] param = new SqlParameter[5];
            int i = 0;
            param[i] = new SqlParameter("ID", SqlDbType.NVarChar);
            param[i++].Value = _model.Id;
            param[i] = new SqlParameter("MaHoaDon", SqlDbType.NVarChar);
            param[i++].Value = _model.MaSanPham;
            param[i] = new SqlParameter("MaSanPham", SqlDbType.NVarChar);
            param[i++].Value = _model.SoLuong;
            param[i] = new SqlParameter("GiaTien", SqlDbType.NVarChar);
            param[i++].Value = _model.SoLuong;
            param[i] = new SqlParameter("SoLuong", SqlDbType.NVarChar);
            param[i++].Value = _model.SoLuong;
            return DataUtil.executeNonStore("sp_ChiTietHoaDon_Update", param);
        }
    }
}
